//package com.weirblog.resource;
//
//import java.util.List;
//
//import javax.enterprise.context.ApplicationScoped;
//import javax.ws.rs.GET;
//import javax.ws.rs.Path;
//import javax.ws.rs.PathParam;
//import javax.ws.rs.Produces;
//import javax.ws.rs.QueryParam;
//import javax.ws.rs.core.MediaType;
//
//import org.apache.commons.lang3.StringUtils;
//
//import com.weirblog.entity.Photo;
//import com.weirblog.entity.Posts;
//import com.weirblog.entity.Video;
//import com.weirblog.vo.IndexVo;
//import com.weirblog.vo.PostView;
//import com.weirblog.vo.page.PageView;
//import com.weirblog.vo.page.QueryResult;
//
//import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
//import io.quarkus.hibernate.orm.panache.PanacheQuery;
//import io.quarkus.panache.common.Parameters;
//import io.quarkus.panache.common.Sort;
//import io.quarkus.panache.common.Sort.Direction;
//import io.quarkus.qute.Template;
//import io.quarkus.qute.TemplateInstance;
//import io.quarkus.qute.api.ResourcePath;
//
//@Path("/")
//@ApplicationScoped
//@Produces(MediaType.TEXT_HTML)
//public class IndexController {
//
//	@ResourcePath("index.html")
//	Template index;
//	@ResourcePath("about.html")
//	Template about;
//	@ResourcePath("me.html")
//	Template me;
//	@ResourcePath("photoList.html")
//	Template photoList;
//	@ResourcePath("videoList.html")
//	Template videoList;
//	@ResourcePath("postView.html")
//	Template postView;
//
////	@RequestMapping(value = "/search", method = RequestMethod.GET)
////	public String search(Integer page,String keyWord,Model model) {
////		if (BaseUtil.isEmpty(keyWord)) {
////			PageView<Posts> pageView = new PageView<Posts>(10, page!=null ? page:1);
////			pageView.setQueryResult(postService.search(pageView.getFirstResult(), pageView.getMaxResult(), keyWord));
////			model.addAttribute("pageView", pageView);
////			model.addAttribute("keyWord", keyWord);
////			return "/WEB-INF/search";
////		}else {
////			return "redirect:/wei";
////		}
////	}
////	
//	@GET
//	@Path("view/{id}")
//	public TemplateInstance postView(@PathParam("id") Integer id) {
//		PostView postViewVo = new PostView();
//		Posts posts = Posts.findById(id);
//		List<Posts> rightNews = Posts.findAll(Sort.by("createDate", Direction.Descending)).page(0, 10).list();
//		List<Posts> rightReads = Posts.findAll(Sort.by("readNum", Direction.Descending)).page(0, 10).list();
//		postViewVo.rightNews = rightNews;
//		postViewVo.rightReads = rightReads;
//		postViewVo.posts = posts;
//		return postView.data("postView", postViewVo);
//	}
//	
//	@GET
//	public TemplateInstance wei(@QueryParam("page") Integer page) {
//		page = page != null ? page : 1;
//		PageView<Posts> pageView = new PageView<Posts>(10, page);
//		PanacheQuery<Posts> panacheQuery = Posts.findAll(Sort.by("createDate", Direction.Descending)).page(page-1, 10);
//		QueryResult<Posts> queryResult = new QueryResult<Posts>();
//		queryResult.setTotalRecord(Long.valueOf(panacheQuery.count()).intValue());
//		queryResult.setResultList(panacheQuery.list());
//		pageView.setQueryResult(queryResult);
//
//		List<Posts> rightReads = Posts.findAll(Sort.by("readNum", Direction.Descending)).page(page - 1, 10).list();
//
//		IndexVo indexVo = new IndexVo();
//		indexVo.index = "weir";
//		indexVo.pageView = pageView;
//		indexVo.rightNews = queryResult.getResultList();
//		indexVo.rightReads = rightReads;
//		return index.data("indexVo", indexVo);
//	}
//	
//	@GET
//	@Path("{u}")
//	public TemplateInstance get(@PathParam("u") String u, @QueryParam("page") Integer page) {
//		page = page != null ? page : 1;
//		if (StringUtils.isBlank(u)) {
//			return index.data("indexVo", null);
//		}
//		List<Posts> rightNews = Posts.findAll(Sort.by("createDate", Direction.Descending)).page(0, 10).list();
//		List<Posts> rightReads = Posts.findAll(Sort.by("readNum", Direction.Descending)).page(0, 10).list();
//		IndexVo indexVo = new IndexVo();
//		if (u.equals("about")) {
//			indexVo.index = "about";
//			indexVo.rightNews = rightNews;
//			indexVo.rightReads = rightReads;
//			return about.data("indexVo", indexVo);
//		}
//		if (u.equals("me")) {
//			return me.data(null);
//		}
//		if (u.equals("photos")) {
//			List<Photo> list = Photo.findAll().list();
//			return photoList.data("photos", list);
//		}
//		if (u.equals("videos")) {
//			List<Video> list = Video.findAll().list();
//			return videoList.data("videos", list);
//		}
//		PageView<Posts> pageView = new PageView<Posts>(10, page);
//		PanacheQuery<Posts> panacheQuery = Posts.find("types like ?1", Sort.by("createDate", Direction.Descending), "%"+u+"%").page(page - 1, 10);
//		QueryResult<Posts> queryResult = new QueryResult<Posts>();
//		queryResult.setTotalRecord(Long.valueOf(panacheQuery.count()).intValue());
//		queryResult.setResultList(panacheQuery.list());
//		pageView.setQueryResult(queryResult);
//		indexVo.pageView = pageView;
//		indexVo.rightNews = rightNews;
//		indexVo.rightReads = rightReads;
//		if (u.equals("weir")) {
//			indexVo.index = "weir";
//			return index.data("indexVo", indexVo);
//		}
//		if (u.equals("java")) {
//			indexVo.index = "java";
//			return index.data("indexVo", indexVo);
//		}
//		return null;
//	}
////	@RequestMapping(value = "/photo",method = RequestMethod.GET)
////	public String photo(HttpServletRequest request,Model model) {
////		List<Photo> photos = photoService.findAll();
////		model.addAttribute("photos", photos);
////		return "/WEB-INF/photo";
////	}
////	@RequestMapping(value = "/video",method = RequestMethod.GET)
////	public String video(HttpServletRequest request,Model model) {
////		List<Video> videos = videoService.findAll();
////		model.addAttribute("videos", videos);
////		return "/WEB-INF/video";
////	}
////
////    @RequestMapping(value = "/upload",method = RequestMethod.GET)
////	public String upload() {
////		return "/WEB-INF/upload";
////	}
////	@RequestMapping(value = "/velocityInit",method = RequestMethod.GET)
////	public void velocityInit(HttpServletRequest request) throws Exception {
////		Properties prop = new Properties();
////		prop.put("runtime.log", request.getServletContext().getRealPath("/WEB-INF/blog/velocity/log/velocity.log"));
////		prop.put("file.resource.loader.path", request.getServletContext().getRealPath("/WEB-INF/blog/velocity/vm"));
////		prop.put("input.encoding", "UTF-8");
////		prop.put("output.encoding", "UTF-8");
////		Velocity.init(prop);
////		return;
////	}
//
//}
